"use strict"

/**
 * 杭州市政府采购网爬虫
 *  
 */

var Base = require("./base");
var hz_spider = new Base();
hz_spider.name = "杭州市政府采购网";
hz_spider.contentType = "text";

hz_spider.getPageUrl = function(pg) {
    return "http://cg.hzft.gov.cn/www/noticelist.do?page.pageNum=" + pg;
};

hz_spider.getItems = function(data) {
    var items = [];
    var reg = new RegExp("<a href=\"(www\/noticedetail.*?)\"[\\s\\S]+?<\/b><\/em>([\\s\\S]+?)<\/a>", "ig");
    var regv;
    while (regv = reg.exec(data)) {
        var url = regv[1];
        var title = regv[2].substring(37);
        var item = {};
        item.title = title;
        item.url = "http://cg.hzft.gov.cn/" + url;
        item.source = hz_spider.name;
        items.push(item);
    }
    return items;
};

exports = module.exports = hz_spider;
